package cn.licoy.wdog.core.service.hospital2.impl;

import cn.licoy.wdog.common.bean.ResponseCode;
import cn.licoy.wdog.common.bean.ResponseResult;
import cn.licoy.wdog.common.exception.RequestException;
import cn.licoy.wdog.core.service.hospital2.FileService;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.FileOutputStream;
import java.util.Date;
import java.util.Random;

/**
 * @Author Sunne
 * @Date $time$ $date$
 * @Param $param$
 * @return $return$
 **/
public class FileServiceImpl implements FileService {
    @Override
    public ResponseResult<String> saveFile(MultipartFile file) {
        return null;
    }

    public static void uploadFile(byte[] file, String filePath, String fileName) throws Exception {
        File targetFile = new File(filePath);
        if(!targetFile.exists()){
            targetFile.mkdirs();
        }
        FileOutputStream out = new FileOutputStream(filePath+fileName);
        out.write(file);
        out.flush();
        out.close();
    }
}
